home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / TwoRings.dxr / 00059_misc. handlers.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  4.4 KB  |  176 lines

  1. global tableau, waste, stock, win, points, pootimer, foundation, deals
  2.  
  3. on createdeck
  4.   facelist = ["ace", "two", "three", "four", "five", "eight", "nine", "ten", "jack", "queen", "king"]
  5.   unsorted_cards = []
  6.   repeat with h in ["hearts", "diamonds", "clubs", "spades"]
  7.     repeat with i = 1 to 11
  8.       repeat with g = 1 to 2
  9.         unsorted_cards.add([#rank: facelist[i], #suit: h])
  10.       end repeat
  11.     end repeat
  12.   end repeat
  13.   shuffledCards = []
  14.   repeat while unsorted_cards.count > 0
  15.     temp = unsorted_cards[random(unsorted_cards.count)]
  16.     shuffledCards.add(temp)
  17.     unsorted_cards.deleteOne(temp)
  18.   end repeat
  19.   return shuffledCards
  20. end
  21.  
  22. on replenish shit
  23.   repeat with i = 1 to shit.count
  24.     stock.cards.add([#rank: shit[i].rank, #suit: shit[i].suit])
  25.   end repeat
  26.   shit.deleteAll()
  27. end
  28.  
  29. on makesymbol arg
  30.   return symbol(string(arg))
  31. end
  32.  
  33. on getlist forthis
  34.   if (forthis >= 31) and (forthis <= 38) then
  35.     return tableau[makesymbol(forthis)].getlastcard()
  36.   end if
  37.   if forthis = 30 then
  38.     return waste.getlastcard()
  39.   end if
  40. end
  41.  
  42. on checkwin
  43.   repeat with i = 1 to foundation.count
  44.     if foundation[i].cards[1].rank = "six" then
  45.       if foundation[i].getlastcard().rankvalue <> 1 then
  46.         exit repeat
  47.       end if
  48.     end if
  49.     if foundation[i].cards[1].rank = "seven" then
  50.       if foundation[i].getlastcard().rankvalue <> 13 then
  51.         exit repeat
  52.       end if
  53.     end if
  54.     if i <> foundation.count then
  55.       next repeat
  56.     end if
  57.     win = "yes"
  58.     pootimer = timeout("poo").new(130, #gotoit)
  59.   end repeat
  60. end
  61.  
  62. on checklose
  63.   if stock.cards.count = 0 then
  64.     if deals = 1 then
  65.       repeat with shits = 30 to 38
  66.         if sprite(shits).member.name = "empty" then
  67.           next repeat
  68.         end if
  69.         repeat with asshole in [13, 16, 23, 24, 25, 26, 27, 28]
  70.           if (getValue(sprite(shits).member.name) = (getValue(sprite(asshole).member.name) - 1)) and (getSuit(sprite(shits).member.name) = getSuit(sprite(asshole).member.name)) then
  71.             abort()
  72.           end if
  73.         end repeat
  74.         repeat with fucknut in [14, 15, 17, 18, 19, 20, 21, 22]
  75.           if (getValue(sprite(shits).member.name) = (getValue(sprite(fucknut).member.name) + 1)) and (getSuit(sprite(shits).member.name) = getSuit(sprite(fucknut).member.name)) then
  76.             abort()
  77.           end if
  78.         end repeat
  79.       end repeat
  80.       win = "no"
  81.       pootimer = timeout("poo").new(130, #gotoit)
  82.     end if
  83.   end if
  84. end
  85.  
  86. on gotoit
  87.   pootimer.forget()
  88.   go("gameover")
  89. end
  90.  
  91. on getValue arg
  92.   if (arg contains "hearts") or (arg contains "spades") then
  93.     return getOff(chars(arg, 1, arg.length - 7))
  94.   else
  95.     if arg contains "diamonds" then
  96.       return getOff(chars(arg, 1, arg.length - 9))
  97.     else
  98.       if arg contains "clubs" then
  99.         return getOff(chars(arg, 1, arg.length - 6))
  100.       end if
  101.     end if
  102.   end if
  103. end
  104.  
  105. on getOff numba
  106.   if numba = "ace" then
  107.     return 1
  108.   else
  109.     if numba = "two" then
  110.       return 2
  111.     else
  112.       if numba = "three" then
  113.         return 3
  114.       else
  115.         if numba = "four" then
  116.           return 4
  117.         else
  118.           if numba = "five" then
  119.             return 5
  120.           else
  121.             if numba = "six" then
  122.               return 6
  123.             else
  124.               if numba = "seven" then
  125.                 return 7
  126.               else
  127.                 if numba = "eight" then
  128.                   return 8
  129.                 else
  130.                   if numba = "nine" then
  131.                     return 9
  132.                   else
  133.                     if numba = "ten" then
  134.                       return 10
  135.                     else
  136.                       if numba = "jack" then
  137.                         return 11
  138.                       else
  139.                         if numba = "queen" then
  140.                           return 12
  141.                         else
  142.                           if numba = "king" then
  143.                             return 13
  144.                           end if
  145.                         end if
  146.                       end if
  147.                     end if
  148.                   end if
  149.                 end if
  150.               end if
  151.             end if
  152.           end if
  153.         end if
  154.       end if
  155.     end if
  156.   end if
  157. end
  158.  
  159. on getSuit arg
  160.   if arg contains "hearts" then
  161.     return #hearts
  162.   else
  163.     if arg contains "diamonds" then
  164.       return #diamonds
  165.     else
  166.       if arg contains "clubs" then
  167.         return #clubs
  168.       else
  169.         if arg contains "spades" then
  170.           return #spades
  171.         end if
  172.       end if
  173.     end if
  174.   end if
  175. end
  176.